<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>区域修改</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    {CSS href="__ADDONSTATIC__css/font.css" /}
    {CSS href="__ADDONSTATIC__css/xadmin.css" /}
    {js href='__ADDONSTATIC__js/jquery-3.2.1.min.js' /}

    {js href='__ADDONSTATIC__js/xadmin.js' /}
    {js href='__ADDONSTATIC__js/util.js' /}
    {js href='__ADDONSTATIC__lib/layui/layui.js' /}
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>区域名称
            </label>
            <div class="layui-input-inline">
                <input type="hidden" name="id"  value="{$area.id}" class="layui-input">
                <input type="text" id="area_name" name="area_name" required="" lay-verify="required"
                       value="{$area.area_name}" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>区域总负责人</label>
            <div class="layui-input-inline" id="manager">
                <select name="manager_id" id="manager_id" lay-verify="required">
                    <option value="0" ></option>
                    {volist name="managers" id="member"}
                    {if condition="$member.id == $area.manager_id"}
                    <option value="{$member.id}" selected>{$member.name}</option>
                    {else/}
                    <option value="{$member.id}">{$member.name}</option>
                    {/if}
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>区域工程负责人</label>
            <div class="layui-input-inline" id="engineer">
                <select name="engineer_id" id="engineer_id" lay-verify="required">
                    <option value="0" ></option>
                    {volist name="engineers" id="member"}
                    {if condition="$member.id == $area.engineer_id"}
                    <option value="{$member.id}" selected>{$member.name}</option>
                    {else/}
                    <option value="{$member.id}">{$member.name}</option>
                    {/if}
                    {/volist}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <button class="layui-btn" lay-filter="update" lay-submit="">
                修改
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form','layer'], function() {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;
        //监听提交
        form.on('submit(update)', function (data) {
            //发异步，把数据提交给php
            ajaxUrl('{:addonUrl('Area/update')}', data.field
                , function (res) {
                    layer.alert(res.message, {}, function () {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        if(res.code == '1'){
                            parent.location.reload();
                        }
                    });
                });
            return false;
        })
    })
</script>
</body>

</html>